import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 页面内容 左侧树
export function getPage(queryParams) {
    const data = {
      ascriptionId: store.state.userInfo.ascriptionId,
      currentPage: queryParams.currentPage,
      pagesize: queryParams.pagesize,
      theType: queryParams.theType   //违规人类型 1-内部员工 2-外委人员
    }
    return request({
      url: '/getViolationPageData',
      method: 'post',
      data: data
    })
}

// 数据列表
export function listData(queryParams) {
    const data = {
      ascriptionId: store.state.userInfo.ascriptionId,
      currentPage: queryParams.currentPage,
      pagesize: queryParams.pagesize,
      keywords: queryParams.keywords,
      categoryId: queryParams.categoryId, //处罚类型 id
      unitId: queryParams.unitId,   //违规人工作单位 id
      deptId: queryParams.deptId    //违规人所属部门 id
    }
    return request({
      url: '/getViolationList',
      method: 'post',
      data: data
    })
}

// 新增
export function addData(val) {
  const data = {
    projectContent:{
      ascriptionId: store.state.userInfo.ascriptionId, //机构 id
      categoryId: val.categoryId, //违章违规类别 id
      category: val.category, //违章违规类别
      personnelType: val.personnelType, //违规人类型 1-内部员工 2-外委人员
      personnelId: val.personnelId, //违规人 id
      personnel: val.personnel, //违规人
      genderId: val.genderId, //性别 1-男 2-女
      genderVal: val.genderVal, //性别
      unitId: val.unitId, //违规人工作单位 id
      workUnit: val.workUnit, //违规人工作单位
      departmentId0: val.departmentId0, //违规人所属部门 id
      department0: val.department0, //违规人所属部门
      workTypeId: val.workTypeId, //工种 id
      workType: val.workType, //工种
      phone: val.phone, //违规人联系电话
      violationTime: val.violationTime, //违规时间
      departmentId: val.departmentId, //监察部门 id
      department: val.department, //监察部门
      supervisorId: val.supervisorId, //监察人 id
      supervisor: val.supervisor, //监察人
      situationDescription: val.situationDescription, //情况说明
      punishmentTime: val.punishmentTime, //处罚日期
    }
  }
  return request({
    url: '/addViolation',
    method: 'post',
    data: data
  })
}

// 获取单条数据
export function getData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getViolationData',
    method: 'post',
    data: data
  })
}

// 修改
export function updateData(val) {
  const data = {
    projectContent:{
      theid: val.theid, //id
      categoryId: val.categoryId, //违章违规类别 id
      category: val.category, //违章违规类别
      personnelType: val.personnelType, //违规人类型 1-内部员工 2-外委人员
      personnelId: val.personnelId, //违规人 id
      personnel: val.personnel, //违规人
      genderId: val.genderId, //性别 1-男 2-女
      genderVal: val.genderVal, //性别
      unitId: val.unitId, //违规人工作单位 id
      workUnit: val.workUnit, //违规人工作单位
      departmentId0: val.departmentId0, //违规人所属部门 id
      department0: val.department0, //违规人所属部门
      workTypeId: val.workTypeId, //工种 id
      workType: val.workType, //工种
      phone: val.phone, //违规人联系电话
      violationTime: val.violationTime, //违规时间
      departmentId: val.departmentId, //监察部门 id
      department: val.department, //监察部门
      supervisorId: val.supervisorId, //监察人 id
      supervisor: val.supervisor, //监察人
      situationDescription: val.situationDescription, //情况说明
      punishmentTime: val.punishmentTime, //处罚日期
    }
  }
  return request({
    url: '/updateViolation',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delViolation',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultiData(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleViolation',
    method: 'post',
    data: data
  })
}

// 下拉框
export function getSelect() {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
  }
  return request({
    url: '/getViolationComboBox',
    method: 'post',
    data: data
  })
}